//
//  IDishLanguageEx.m
//  XRmenu
//
//  Created by yangxh on 11-3-24.
//  Copyright 2011 E0571. All rights reserved.
//

#import "IDishLanguageEx.h"


@implementation IDishLanguageEx

@synthesize briefEx;
@synthesize commentEx;
@synthesize language;
@synthesize materialEx;
@synthesize nameEx;
@synthesize recipesEx;
@synthesize unit;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
    return [self initWithBriefEx:nil commentEx:nil language:nil materialEx:nil nameEx:nil recipesEx:nil unit:nil];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithBriefEx:(NSString*)aBriefEx commentEx:(NSString*)aCommentEx language:(NSString*)aLanguage materialEx:(NSString*)aMaterialEx nameEx:(NSString*)aNameEx recipesEx:(NSString*)aRecipesEx unit:(NSString*)anUnit 
{
    self = [super init];
    if (self) {
        self.briefEx = aBriefEx;
        self.commentEx = aCommentEx;
        self.language = aLanguage;
        self.materialEx = aMaterialEx;
        self.nameEx = aNameEx;
        self.recipesEx = aRecipesEx;
        self.unit = anUnit;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithBriefEx:(NSString*)aBriefEx commentEx:(NSString*)aCommentEx language:(NSString*)aLanguage materialEx:(NSString*)aMaterialEx nameEx:(NSString*)aNameEx recipesEx:(NSString*)aRecipesEx unit:(NSString*)anUnit  
{
    id result = [[[self class] alloc] initWithBriefEx:aBriefEx commentEx:aCommentEx language:aLanguage materialEx:aMaterialEx nameEx:aNameEx recipesEx:aRecipesEx unit:anUnit];
	
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
					   @"briefEx",
					   @"commentEx",
					   @"language",
					   @"materialEx",
					   @"nameEx",
					   @"recipesEx",
					   @"unit",
					   nil];
	
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
	
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
	
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
	return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [briefEx release];
    briefEx = nil;
    [commentEx release];
    commentEx = nil;
    [language release];
    language = nil;
    [materialEx release];
    materialEx = nil;
    [nameEx release];
    nameEx = nil;
    [recipesEx release];
    recipesEx = nil;
    [unit release];
    unit = nil;
	
    [super dealloc];
}

+ (IDishLanguageEx *)iDishLanguageExByParse:(NSDictionary *)info
{
	IDishLanguageEx *dishEx = [IDishLanguageEx objectWithBriefEx:dictObject(info,@"Brief")
													   commentEx:dictObject(info,@"Comment")
														language:dictObject(info,@"LanguageId")
													  materialEx:dictObject(info,@"Material")
														  nameEx:dictObject(info,@"Name")
													   recipesEx:dictObject(info,@"Recipes") 
															unit:dictObject(info,@"Calorie")];
	return dishEx;
}

@end
